package com.ledi.guns.modular.ledipay.controller;

import io.swagger.annotations.Api;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.plugins.Page;
import com.ledi.guns.common.annotion.Permission;
import com.ledi.guns.common.persistence.model.SmsSend;
import com.ledi.guns.common.persistence.model.vo.SmsSchoolUseVo;
import com.ledi.guns.common.persistence.page.PageQuery;
import com.ledi.guns.core.base.tips.SuccessTip;
import com.ledi.guns.core.base.tips.Tip;
import com.ledi.guns.modular.ledipay.controller.feignClients.req.SchoolSmsUseReq;
import com.ledi.guns.modular.ledipay.controller.feignClients.req.SmsPackageReq;
import com.ledi.guns.modular.ledipay.controller.feignClients.req.SmsPackageReq.SaveSmsPackage;
import com.ledi.guns.modular.ledipay.controller.feignClients.req.SmsPackageReq.UpdateSmsPackage;
import com.ledi.guns.modular.ledipay.controller.feignClients.req.SmsSchoolGiveReq;
import com.ledi.guns.modular.ledipay.controller.feignClients.req.SmsSchoolRecord;
import com.ledi.guns.modular.ledipay.controller.feignClients.req.SmsSchoolReq;
import com.ledi.guns.modular.ledipay.controller.req.sms.GetCode;
import com.ledi.guns.modular.ledipay.controller.req.sms.PromptPaymentReq;
import com.ledi.guns.modular.ledipay.controller.req.sms.SmsSendRecordReq;
import com.ledi.guns.modular.ledipay.service.SmsService;

/**
 * 文件名称： com.ledi.guns.modular.ledipay.controller.SmsController.java<br/>
 * 初始作者： 钟小平<br/>
 * 创建日期： 2018年7月9日<br/>
 * 功能说明： 短信管理Controller <br/>
 * =================================================<br/>
 * 修改记录：<br/>
 * 修改作者 日期 修改内容<br/>
 * ================================================<br/>
 * Copyright (乐迪教育科技有限公司-幼儿事业部) 2017-2018.All rights reserved.<br/>
 */
@Api
@RestController
@RequestMapping("/smsPackege")
public class SmsController {

	protected final static Logger logger = LoggerFactory.getLogger(SmsController.class);

	@Resource
	private SmsService smsService;

	/**
	 * @api {GET} /smsPackege/list 套餐列表
	 * @apiGroup smsPackege
	 * @apiName list
	 * @apiParam {int} status 状态（0下架，1上架）
	 * @apiSuccess {int} smsCount 短信数目
	 * @apiSuccess {int} giveSmsCount 赠送短信数目
	 * @apiSuccess {bigDecimal} originPrice 原价
	 * @apiSuccess {bigDecimal} presentPrice 现价
	 * @apiSuccess {String} name 套餐名称
	 * @apiSuccess {int} newFlag 上线七天内标识
	 * @apiSuccess {int} status 状态（0下架，1上架）
	 * @apiSuccess {Integer} versionNo 版本号
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "id": "XX",
	 *                  "schoolContactPeople":"张三"
	 *                  "startTime":"2017-11-20 16:54:32"
	 *                  "endTime":"2017-12-20 16:54:32"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": [
	 *                    {
	 *                    "presentPrice": 15,
	 *                    "createTime": "2018-07-09 16:40:01",
	 *                    "updaterId": "",
	 *                    "smsCount": 500,
	 *                    "creatorId": 1,
	 *                    "name": "金华火腿套餐",
	 *                    "versionNo": 0,
	 *                    "updateTime": "",
	 *                    "id": 1,
	 *                    "originPrice": 20,
	 *                    "giveSmsCount": 20,
	 *                    "status": 0
	 *                    }
	 *                    ],
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public Object getSchoolInfoList(@RequestParam(value = "status", required = false) Integer status) {

		return smsService.list(status);
	}

	/**
	 * @api {POST} /smsPackege/add 套餐添加
	 * @apiGroup smsPackege
	 * @apiName add
	 * @apiParam {int} smsCount 短信数目
	 * @apiParam {int} giveSmsCount 赠送短信数目
	 * @apiParam {bigDecimal} originPrice 原价
	 * @apiParam {bigDecimal} presentPrice 现价
	 * @apiParam {String} name 套餐名称
	 * @apiParam {int} status 状态（0下架，1上架）
	 * @apiSuccess {Integer} versionNo 版本号
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "presentPrice": 15,
	 *                  "smsCount": 500,
	 *                  "name": "金华火腿套餐",
	 *                  "originPrice": 20,
	 *                  "giveSmsCount": 20,
	 *                  "status": 0
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public Object add(@RequestBody @Validated(SaveSmsPackage.class) SmsPackageReq param) {

		return smsService.add(param);
	}

	/**
	 * @api {PUT} /smsPackege/update 套餐修改
	 * @apiGroup smsPackege
	 * @apiName update
	 * @apiParam {int} status 0下架1上架
	 * @apiParam {int} id id
	 * @apiParam {Integer} versionNo 版本号
	 * @apiParam {int} smsCount 短信数目
	 * @apiParam {int} giveSmsCount 赠送短信数目
	 * @apiParam {bigDecimal} originPrice 原价
	 * @apiParam {bigDecimal} presentPrice 现价
	 * @apiParam {String} name 套餐名称
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "presentPrice": 15,
	 *                  "createTime": "2018-07-09 16:40:01",
	 *                  "updaterId": "",
	 *                  "smsCount": 500,
	 *                  "creatorId": 1,
	 *                  "name": "金华火腿套餐",
	 *                  "versionNo": 0,
	 *                  "id": 1,
	 *                  "originPrice": 20,
	 *                  "giveSmsCount": 20,
	 *                  "status": 0
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/update", method = RequestMethod.PUT)
	public Object update(@RequestBody @Validated(UpdateSmsPackage.class) SmsPackageReq param) {

		return smsService.add(param);
	}

	/**
	 * @api {PUT} /smsPackege/statusChange 上架下架
	 * @apiGroup smsPackege
	 * @apiName statusChange
	 * @apiParam {int} status 0下架1上架
	 * @apiParam {int} id id
	 * @apiParam {Integer} versionNo 版本号
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "presentPrice": 15,
	 *                  "createTime": "2018-07-09 16:40:01",
	 *                  "updaterId": "",
	 *                  "smsCount": 500,
	 *                  "creatorId": 1,
	 *                  "name": "金华火腿套餐",
	 *                  "versionNo": 0,
	 *                  "id": 1,
	 *                  "originPrice": 20,
	 *                  "giveSmsCount": 20,
	 *                  "status": 0
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/statusChange", method = RequestMethod.PUT)
	public Object statusChange(@RequestBody @Validated({ UpdateSmsPackage.class }) SmsPackageReq param) {

		return smsService.statusChange(param);
	}

	/**
	 * @api {DELETE} /smsPackege/delete 套餐删除
	 * @apiGroup smsPackege
	 * @apiName delete
	 * @apiParam {int} id id
	 * @apiParam {Integer} versionNo 版本号
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
	public Object delete(@RequestBody @Validated({ UpdateSmsPackage.class }) SmsPackageReq param) {

		return smsService.delete(param);
	}

	/**
	 * @api {POST} /smsPackege/saveSmsSchoolGive 修改学校短信分配
	 * @apiGroup smsPackege
	 * @apiName saveSmsSchoolGive
	 * @apiParam {int} schoolId 学校Id
	 * @apiParam {int} giveCount 赠送短信条数
	 * @apiParam {String} freeMonth 赠送月份(1,2,3...)
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "id": "XX",
	 *                  "schoolContactPeople":"张三"
	 *                  "startTime":"2017-11-20 16:54:32"
	 *                  "endTime":"2017-12-20 16:54:32"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": [
	 *                    {
	 *                    "presentPrice": 15,
	 *                    "createTime": "2018-07-09 16:40:01",
	 *                    "updaterId": "",
	 *                    "smsCount": 500,
	 *                    "creatorId": 1,
	 *                    "name": "金华火腿套餐",
	 *                    "versionNo": 0,
	 *                    "updateTime": "",
	 *                    "id": 1,
	 *                    "originPrice": 20,
	 *                    "giveSmsCount": 20,
	 *                    "status": 0
	 *                    }
	 *                    ],
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/saveSmsSchoolGive", method = RequestMethod.POST)
	public Object saveSmsSchoolGive(@RequestBody @Validated({ SaveSmsPackage.class }) SmsSchoolGiveReq param) {

		smsService.addSchoolSmsGive(param);
		return SuccessTip.buildSuccess();
	}

	/**
	 * @api {GET} /smsPackege/officialPrice 腾讯阿里云短信收费情况列表
	 * @apiGroup smsPackege
	 * @apiName officialPrice
	 * @apiSuccess {String} type 套餐类型（腾讯、阿里）
	 * @apiSuccess {int} count 数目
	 * @apiSuccess {bigDecimal} price 单价
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": [
	 *                    {
	 *                    "price": 0.0306,
	 *                    "count": 3000000,
	 *                    "id": 11,
	 *                    "type": "阿里云"
	 *                    },
	 *                    {
	 *                    "price": 0.32,
	 *                    "count": 1000000,
	 *                    "id": 10,
	 *                    "type": "阿里云"
	 *                    },
	 *                    {
	 *                    "price": 0.34,
	 *                    "count": 5000000,
	 *                    "id": 9,
	 *                    "type": "阿里云"
	 *                    },
	 *                    {
	 *                    "price": 0.38,
	 *                    "count": 500000,
	 *                    "id": 8,
	 *                    "type": "阿里云"
	 *                    },
	 *                    {
	 *                    "price": 0.38,
	 *                    "count": 50000,
	 *                    "id": 7,
	 *                    "type": "阿里云"
	 *                    },
	 *                    {
	 *                    "price": 0.42,
	 *                    "count": 5000,
	 *                    "id": 6,
	 *                    "type": "阿里云"
	 *                    },
	 *                    {
	 *                    "price": 0.036,
	 *                    "count": 3000000,
	 *                    "id": 5,
	 *                    "type": "腾讯云"
	 *                    },
	 *                    {
	 *                    "price": 0.037,
	 *                    "count": 1000000,
	 *                    "id": 4,
	 *                    "type": "腾讯云"
	 *                    },
	 *                    {
	 *                    "price": 0.038,
	 *                    "count": 500000,
	 *                    "id": 3,
	 *                    "type": "腾讯云"
	 *                    },
	 *                    {
	 *                    "price": 0.04,
	 *                    "count": 100000,
	 *                    "id": 2,
	 *                    "type": "腾讯云"
	 *                    },
	 *                    {
	 *                    "price": 0.045,
	 *                    "count": 10000,
	 *                    "id": 1,
	 *                    "type": "腾讯云"
	 *                    }
	 *                    ],
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/officialPrice", method = RequestMethod.GET)
	public Object officialPrice() {

		return smsService.officialPrice();
	}

	/**
	 * @api {POST} /smsPackege/smsSchoolList 短信列表
	 * @apiGroup smsPackege
	 * @apiName smsSchoolList
	 * @apiParam {int} schoolId 学校id
	 * @apiParam {int} packageId 套餐id
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiSuccess {String} packageName 套餐名称
	 * @apiSuccess {String} schoolName 充值学校
	 * @apiSuccess {String} dealNo 交易编号
	 * @apiSuccess {String} statusZh 交易状态（待支付、已支付）
	 * @apiSuccess {Integer} status 交易状态（0待支付、1已支付）
	 * @apiSuccess {String} payWayZh 支付方式（微信、支付宝）
	 * @apiSuccess {Integer} payWay 支付方式（1微信、0支付宝）
	 * @apiSuccess {Integer} smsCount 短信数目
	 * @apiSuccess {Integer} giveSmsCount 赠送短信数目
	 * @apiSuccess {Integer} originPrice 原价
	 * @apiSuccess {Integer} presentPrice 现价
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "schoolId": "XX",
	 *                  "packageId":"张三"
	 *                  "startTime":"2017-11-20 16:54:32"
	 *                  "endTime":"2017-12-20 16:54:32"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "current": 1,
	 *                    "total": 11,
	 *                    "pages": 2,
	 *                    "records": [
	 *                    {
	 *                    "orderNo": 21312323,
	 *                    "smsCount": 0,
	 *                    "payWayZh": "支付宝",
	 *                    "creatorId": 1,
	 *                    "packageId": 1,
	 *                    "payWay": 0,
	 *                    "updateTime": "2018-07-12 14:01:48",
	 *                    "originPrice": 0,
	 *                    "dealNo": 122323,
	 *                    "giveSmsCount": 0,
	 *                    "presentPrice": 0,
	 *                    "createTime": "2018-07-12 14:01:40",
	 *                    "updaterId": 1,
	 *                    "payPrice": 5000,
	 *                    "schoolId": 1,
	 *                    "name": "菊花套餐",
	 *                    "statusZh": "未到账",
	 *                    "id": 11,
	 *                    "schoolName": "110",
	 *                    "status": 0
	 *                    }
	 *                    ]
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/smsSchoolList", method = RequestMethod.POST)
	public Object getsmsSchoolList(@RequestBody SmsSchoolReq SmsSchoolReq) {

		return smsService.smsSchoolList(SmsSchoolReq);
	}

	/**
	 * @api {POST} /smsPackege/smsSchoolUseList 学校短信使用记录
	 * @apiGroup smsPackege
	 * @apiName smsSchoolUseList
	 * @apiParam {int} schoolId 学校id
	 * @apiParam {Date} time 查询年月
	 * @apiSuccess {String} schoolName 学校名称
	 * @apiSuccess {String} schoolId 学校id
	 * @apiSuccess {Integer} smsCount 短信数目
	 * @apiVersion 1.4.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "schoolId": "XX",
	 *                  "time":"2017-12"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "asc": true,
	 *                    "condition": "",
	 *                    "current": 1,
	 *                    "limit": 2147483647,
	 *                    "offset": 0,
	 *                    "offsetCurrent": 0,
	 *                    "openSort": true,
	 *                    "orderByField": "",
	 *                    "pages": 1,
	 *                    "records": [
	 *                    {
	 *                    "schoolId": 94,
	 *                    "schoolName": "123123",
	 *                    "smsUseCount": 4
	 *                    },
	 *                    {
	 *                    "schoolId": 29,
	 *                    "schoolName": "胡哥的粉丝团",
	 *                    "smsUseCount": 2
	 *                    },
	 *                    {
	 *                    "schoolId": 1,
	 *                    "schoolName": "乐迪yuyu",
	 *                    "smsUseCount": 2
	 *                    }
	 *                    ],
	 *                    "searchCount": true,
	 *                    "size": 10,
	 *                    "total": 3
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/smsSchoolUseList", method = RequestMethod.POST)
	public Object smsSchoolUseList(@RequestBody SchoolSmsUseReq schoolSmsUseReq) {

		schoolSmsUseReq.checkOrder(SmsSchoolUseVo.class);
		Page<SmsSchoolUseVo> page = smsService.smsSchoolUseList(new Page<SmsSchoolUseVo>(schoolSmsUseReq.getPageNo(), schoolSmsUseReq.getPageSize()), schoolSmsUseReq);
		return SuccessTip.buildSuccess(page);
	}

	/**
	 * @api {POST} /smsPackege/smsBuyList 后台短信充值记录列表
	 * @apiGroup smsPackege
	 * @apiName smsBuyList
	 * @apiSuccess {String} creatorName 充值人
	 * @apiSuccess {String} createTime 充值时间
	 * @apiSuccess {Integer} smsBuyCount 充值数目
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "current": 1,
	 *                    "total": 1,
	 *                    "pages": 1,
	 *                    "records": [
	 *                    {
	 *                    "createTime": "2018-07-13 10:37:59",
	 *                    "updaterId": 1,
	 *                    "smsBuyCount": 100,
	 *                    "creatorId": 1,
	 *                    "creatorName": "哈哈",
	 *                    "balanceCount": 100,
	 *                    "updateTime": "2018-07-13 10:38:08",
	 *                    "id": 1
	 *                    }
	 *                    ]
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/smsBuyList", method = RequestMethod.POST)
	public Object smsBuyList(@RequestBody PageQuery query) {

		return smsService.smsBuyList(query);
	}

	/**
	 * @api {POST} /smsPackege/smsBuy 后台短信充值（form）
	 * @apiGroup smsPackege
	 * @apiName smsBuy
	 * @apiParam {Long} smsBuyCount 充值条数
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/smsBuy", method = RequestMethod.POST)
	public Object saveSmsSchoolGive(@RequestParam("smsBuyCount") Long smsBuyCount) {

		smsService.addSmsBuy(smsBuyCount);
		return SuccessTip.buildSuccess();
	}

	/**
	 * @api {GET} /smsPackege/smsBuyBalance 后台短信余额
	 * @apiGroup smsPackege
	 * @apiName smsBuyBalance
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/smsBuyBalance", method = RequestMethod.GET)
	public Object smsBuyBalance() {

		return SuccessTip.buildSuccess(smsService.getSmsBuyBalance());
	}

	/**
	 * @api {GET} /smsPackege/smsSchoolBalance 学校短信余额
	 * @apiGroup smsPackege
	 * @apiName smsSchoolBalance
	 * @apiSuccess {int} schoolCanUseBalance 学校可用短信余额
	 * @apiSuccess {int} currentMonthfreeBalance 当月剩余赠送短信额度
	 * @apiSuccess {int} currentMonthfreeCount 本月赠送短信总量
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/smsSchoolBalance", method = RequestMethod.GET)
	public Object smsSchoolBalance() {

		return SuccessTip.buildSuccess(smsService.getSmsSchoolBalance());
	}

	/**
	 * @api {POST} /smsPackege/schoolRecordAdd 学校短信预充值
	 * @apiGroup smsPackege
	 * @apiName schoolRecordAdd
	 * @apiParam {int} packageId 套餐id
	 * @apiParam {int} versionNo 套餐版本号
	 * @apiSuccess {Integer} versionNo 版本号
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "packageId": 15,
	 *                  "versionNo": 500
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/schoolRecordAdd", method = RequestMethod.POST)
	public Object schoolRecordAdd(@RequestBody @Validated({ SaveSmsPackage.class }) SmsSchoolRecord param) {

		return smsService.addSchoolRecord(param);
	}

	/**
	 * @api {GET} /smsPackege/smsPay/{orderNo} 学校短信支付成功
	 * @apiGroup smsPackege
	 * @apiName smsPay
	 * @apiParam {String} orderNo 订单编号
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/smsPay/{orderNo}", method = RequestMethod.GET)
	public Object smsPay(@PathVariable("orderNo") String orderNo) {

		smsService.successCheckSchoolSmsRecord(orderNo);

		return SuccessTip.buildSuccess();
	}

	/**
	 * @api {GET} /smsPackege/getSchoolRecord/{orderNo} 获取学校短信订单
	 * @apiGroup smsPackege
	 * @apiName getSchoolRecord
	 * @apiParam {int} orderNo 订单编号
	 * @apiSuccess {String} packageName 套餐名称
	 * @apiSuccess {String} schoolName 充值学校
	 * @apiSuccess {String} dealNo 交易编号
	 * @apiSuccess {String} statusZh 交易状态（待支付、已支付）
	 * @apiSuccess {Integer} status 交易状态（0待支付、1已支付）
	 * @apiSuccess {String} payWayZh 支付方式（微信、支付宝）
	 * @apiSuccess {Integer} payWay 支付方式（1微信、0支付宝）
	 * @apiSuccess {Integer} smsCount 短信数目
	 * @apiSuccess {Integer} giveSmsCount 赠送短信数目
	 * @apiSuccess {Integer} originPrice 原价
	 * @apiSuccess {Integer} presentPrice 现价
	 * @apiSuccess {String} sign 签名
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "alipayNumber": "",
	 *                    "createTime": "2018-07-21 10:42:35",
	 *                    "creatorId": 87,
	 *                    "dealNo": "",
	 *                    "giveSmsCount": 20,
	 *                    "id": 56,
	 *                    "name": "炸鸡胡旭阳套餐",
	 *                    "orderNo": 1020499251447742465,
	 *                    "originPrice": 20.2,
	 *                    "packageId": 19,
	 *                    "payTime": "",
	 *                    "payWay": "",
	 *                    "payee": "",
	 *                    "presentPrice": 20,
	 *                    "schoolId": 29,
	 *                    "schoolName": "正式PID",
	 *                    "sign": "23E93AD8BEA9BFC47752A736894DD2E3",
	 *                    "smsCount": 500,
	 *                    "status": 0,
	 *                    "subMchId": "",
	 *                    "updateTime": "",
	 *                    "updaterId": "",
	 *                    "versionNo": ""
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/getSchoolRecord/{orderNo}", method = RequestMethod.GET)
	public Object getSchoolRecord(@PathVariable("orderNo") String orderNo) {

		SmsSchoolRecord sr = smsService.getSchoolRecord(orderNo);
		return SuccessTip.buildSuccess(sr);
	}

	/**
	 * @api {POST} /smsPackege/prePay 微信下单接口
	 * @apiGroup smsPackege
	 * @apiName prePay
	 * @apiParam orderNo 订单编号
	 * @apiParam code 用户code
	 * @apiParam orderSign 签名
	 * @apiSuccess appId appid
	 * @apiSuccess timeStamp 时间戳
	 * @apiSuccess package 微信预支付编码
	 * @apiSuccess sign 微信签名
	 * @apiSuccess nonceStr 微信随机码
	 * @apiSuccess code 返回编码（200成功）
	 * @apiSuccess message 返回说明
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 * @apiVersion 2.0.0
	 */
	@RequestMapping(value = "/prePay", method = RequestMethod.POST)
	@CrossOrigin
	public Tip prePay(@RequestBody GetCode getCode, HttpServletRequest request) {

		Map<String, String> map = smsService.prePay(getCode, request);
		return SuccessTip.buildSuccess(map);

	}

	/**
	 * @api {POST} /smsPackege/promptPayment 短信催缴费
	 * @apiGroup smsPackege
	 * @apiName promptPayment
	 * @apiParam {Array} mobileAndBill 电话号码和账单。
	 * @apiParam {String} ...mobile 手机号
	 * @apiParam {Long} ...billDetailId 账单详情id
	 * @apiSuccess code 返回编码（200成功）
	 * @apiSuccess message 返回说明
	 * @apiSuccess data 成功条数
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "mobileAndBill": [
	 *                  {"mobile":"18992638131","billDetailId":2},
	 *                  {"mobile":"18992638131","billDetailId":2},
	 *                  {"mobile":"18992638131","billDetailId":2}
	 *                  ]
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功",
	 *                    "data":1
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/promptPayment", method = RequestMethod.POST)
	public Object promptPayment(@RequestBody @Validated({ SaveSmsPackage.class }) PromptPaymentReq param) {

		return SuccessTip.buildSuccess(smsService.promptPayment(param));
	}

	/**
	 * @api {POST} /smsPackege/smsSchoolSendList 学校短信消费情况
	 * @apiGroup smsPackege
	 * @apiName smsSchoolSendList
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiParam {int} userId 用户id
	 * @apiParam {int} classId 班级id
	 * @apiParam {int} status 短信状态（0异常，1正常）
	 * @apiVersion 1.3.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "asc": true,
	 *                    "condition": "",
	 *                    "current": 1,
	 *                    "limit": 2147483647,
	 *                    "offset": 0,
	 *                    "offsetCurrent": 0,
	 *                    "openSort": true,
	 *                    "orderByField": "",
	 *                    "pages": 1,
	 *                    "records": [
	 *                    {
	 *                    "classId": 1,
	 *                    "className": "水电费",
	 *                    "createTime": "2018-07-18 18:23:15",
	 *                    "creatorId": 1,
	 *                    "creatorName": "123sf",
	 *                    "creatorRole": "ss",
	 *                    "id": 1,
	 *                    "mobile": "175265156265",
	 *                    "schoolId": 1,
	 *                    "sendName": "张晓峰",
	 *                    "status": 1
	 *                    }
	 *                    ],
	 *                    "searchCount": true,
	 *                    "size": 10,
	 *                    "total": 1
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/smsSchoolSendList", method = RequestMethod.POST)
	public Object smsSendList(@RequestBody SmsSendRecordReq query) {

		query.checkOrder(SmsSend.class);
		Page<SmsSend> page = smsService.smsSchoolSendList(new Page<SmsSend>(query.getPageNo(), query.getPageSize()), query);
		return SuccessTip.buildSuccess(page);

	}

}
